/*
    filename is D:\Projects\sxwf-webapp\src\routes\index.js
    Created by guangluo on 08/14/2020
*/

import React from 'react'
import styles from '../styles.less'

const homeData = [{
  title: '掌上无废',
  children: [{
    title: '三张清单',
    icon: 1,
    url: '/App/threeLists'
  }, {
    title: '指标分析',
    icon: 2,
    url: '/App/indicatorAnaysis'
  }, {
    title: '工作报告',
    icon: 3,
    url: '/App/workReport'
  }]
}, {
  title: '日常工作',
  children: [{
    title: '工作台',
    icon: 4,
    url: '/App/workbench'
  }, {
    title: '通知公告',
    icon: 5,
    url: '/App/announcement',
  }, {
    title: '公文管理',
    icon: 6,
    url: '/App/documentManagement'
  }]
}, {
  title: '相关拓展',
  children: [{
    title: '管理制度',
    icon: 7,
    url: '/App/managementSystem'
  }, {
    title: '企业信息',
    icon: 8,
    url: '/App/corporateInformation',
  }, {
    title: '综合查询',
    icon: 9,
    url: '/App/integratedQuery'
  }, {
    title: '政策法规',
    icon: 10,
    url: '/App/policiesRegulations'
  }]
}]

export default class HomePage extends React.Component {
  handleClick = (url) => {
    this.props.history.push(url)
  }

  render() {
    return (
      <div className={styles.wrapper}>
        {
          homeData.map(item => (
            <div
              key={item.title}
            >
              <div className={styles.container_title}>{item.title}</div>
              <div className={styles.container}>
                {
                  item.children ? item.children.map(val => (
                    <div
                      key={val.title}
                      className={styles.img_container}
                      onClick={() => this.handleClick(val.url)}>
                      <img src={require('../../assets/image/HomePage/' + val.icon + '.png')} alt="" className={styles.img} />
                      <div className={styles.title}>{val.title}</div>
                    </div>
                  )) : null
                }
              </div>
            </div>
          ))
        }
      </div>
    )
  }
}
